import { isArray } from './types'

export const unique = <T>(arr: T[]) => [...new Set(arr)]

type Many<T> = T | ReadonlyArray<T>
export const castArray = <T>(arr: Many<T>): T[] => {
  if (!arr && (arr as unknown) !== 0) return []
  return isArray(arr) ? arr : [arr as T]
}

export { orderBy } from 'xe-utils'
